# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gsettings-desktop-schemas
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=40.0
pkgrel=2
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://wiki.gnome.org/"
pkgdesc="Shared GSettings schemas for the desktop (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-adobe-source-code-pro-fonts"
              $([[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]] || \
              echo "${MINGW_PACKAGE_PREFIX}-cantarell-fonts")) # Remove this workaround after vala available
makedepends=("${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja")
license=('LGPL2.1')
options=('strip' 'staticlibs')
install=schemas-${MSYSTEM}.install
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz"
        "001-fix-pkg-config-file.patch")
sha256sums=('f1b83bf023c0261eacd0ed36066b76f4a520bbcb14bb69c402b7959257125685'
            '6c85093ac2efcf51379bc697fda56ccd6447137ac1a464934f2b18ea0d1f4cb3')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/001-fix-pkg-config-file.patch

}

build() {
  rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Dintrospection=true \
    ../${_realname}-${pkgver}

  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  DESTDIR="${pkgdir}" ninja install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
